﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Entities;
using System.Collections.Generic;
using BLL;

namespace RailwayReservationSystem.Client
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Load_Data();
        }

        protected void btnSearch_Click(object sender, ImageClickEventArgs e)
        {
            //(int StationFrom, int StationTo, String date, int CoachTypeID)
            String StationFrom = ddlFrom.SelectedItem.Value;
            String StationTo = ddlTo.SelectedItem.Value;
            String CoachTypeID = ddlClass.SelectedValue;
            String Date = txtDate.Text.Trim();
            String URL = "FindTrain.aspx?StationFrom=" + StationFrom + "&StationTo=" + StationTo + "&CoachTypeID=" + CoachTypeID + "&Date=" + Date;
            Response.Redirect(URL);
        }

        private void Load_Data()
        {
            List<Station> ListStation = StationBUS.GetStation();
            List<CoachType> ListCoachType = CoachTypeBUS.GetCoachType();

            ddlTo.DataSource = ddlFrom.DataSource = ListStation;
            ddlClass.DataSource = ListCoachType;

            ddlFrom.DataBind();
            ddlTo.DataBind();
            ddlClass.DataBind();
        }
    }
}